package com.example.mynewsweb.service;

import com.example.mynewsweb.dao.CommentDao;
import com.example.mynewsweb.po.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CommentServiceImpl implements CommentService{
    @Autowired
    private CommentDao commentDao;

    /*发布评论*/
    @Override
    public void addComment(Comment comment) {
        commentDao.addComment(comment);
    }
    /*显示当前新闻的评论*/
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Comment> showComment(String newId) {
        return commentDao.showComment(newId);
    }

    @Override
    public void deleteComment(String newId) {
        commentDao.deleteComment(newId);
    }

    @Override
    public void updateCommentUser(Comment comment) {
        commentDao.updateCommentUser(comment);
    }

    @Override
    public List<Comment> findComment(String userId) {
        return commentDao.findComment(userId);
    }
}
